﻿
Namespace Aricie.DNN.Services.Url.FriendlyUrl.SimpleAPI

    ''' <summary>
    ''' The base class for providers working with the SimpleAPI.
    ''' </summary>
    ''' <remarks></remarks>
    Public MustInherit Class SimpleRewriterProvider
        Implements IUrlRewriterProvider

        ''' <summary>
        ''' This method should be called by the FUP engine only
        ''' </summary>
        ''' <returns>A list of GroupParamsRewrite</returns>
        ''' <remarks></remarks>
        Public Function GetRewrites() As System.Collections.Generic.List(Of GroupParamsRewrite) Implements IFriendlyUrlGroupProvider.GetRewrites
            Return GetRewritingGroups().ConvertAll(New Converter(Of SimpleGroupParamsRewrite, GroupParamsRewrite)(Function(sgpr) DirectCast(sgpr, GroupParamsRewrite)))
        End Function

        ''' <summary>
        ''' In the SimpleAPI, this method should never be called. It will throw an exception if you do.
        ''' </summary>
        ''' <param name="groupName"></param>
        ''' <param name="objRewriteType"></param>
        ''' <param name="params"></param>
        ''' <param name="behaviour"></param>
        ''' <returns></returns>
        ''' <remarks>Throws NotImplementedException</remarks>
        Public Function RewriteParams(ByVal groupName As String, ByVal objRewriteType As RewriteType, ByVal params As System.Collections.Generic.Dictionary(Of UrlParam, String), ByVal behaviour As FriendlierUrlStrategy) As GroupRewriteResult Implements IUrlRewriterProvider.RewriteParams
            Throw New NotImplementedException("RewriteParams not implemented, your GroupRewriteParams should handle rewriting by themselves")
        End Function

        ''' <summary>
        ''' The method a provider inheriting SimpleRewriterProvider needs to use
        ''' </summary>
        ''' <returns>A list of SimpleGroupParamsRewrite</returns>
        ''' <remarks></remarks>
        Protected MustOverride Function GetRewritingGroups() As List(Of SimpleGroupParamsRewrite)
    End Class

End Namespace